<template>
  <div class="upload-area">
    <input type="file" @change="validatePackage" accept=".deb,.uab"/>
    <p v-if="error" class="error">{{ error }}</p>
  </div>
</template>

<script>
export default {
  methods: {
    async validatePackage(e) {
      const file = e.target.files[0];
      const validTypes = ['application/vnd.debian.binary-package', 'application/x-archive'];
      
      if (!validTypes.includes(file.type)) {
        this.error = '仅支持DEB/玲珑包格式';
        return;
      }
      
      // 深度格式校验逻辑
      if (file.name.endsWith('.deb')) {
        await this.validateDebStructure(file);
      }
    },
    
    async validateDebStructure(file) {
      const reader = new FileReader();
      reader.onload = (e) => {
        const arr = new Uint8Array(e.target.result);
        if (arr[0] !== 0x21 || arr[1] !== 0x0A) { // DEB magic number
          this.error = '无效的DEB文件结构';
        }
      };
      reader.readAsArrayBuffer(file);
    }
  }
}
</script>